package api

import (
	"django_blog_gin/internal/svc"

	"github.com/gin-gonic/gin"
)

type blogHandler struct {
	ImportMdFile                     gin.HandlerFunc
	ArticleList                      gin.HandlerFunc
	UpdateArticle                    gin.HandlerFunc
	GetArticleDetail                 gin.HandlerFunc
	GetArticleWithTagsList           gin.HandlerFunc
	GetArticleWithTagDetail          gin.HandlerFunc
	GetArticleWithTagsListForPrivate gin.HandlerFunc
	CreateArticle                    gin.HandlerFunc
	GetHotArticle                    gin.HandlerFunc

	BlogSettingsList   gin.HandlerFunc
	UpdateBlogSettings gin.HandlerFunc
}

func NewBlogHandler(svcCtx *svc.ServiceContext) *blogHandler {
	ctr := NewBlogArticleController(svcCtx)
	return &blogHandler{
		ImportMdFile:                     ctr.ImportMdField,
		ArticleList:                      ctr.GetArticleList,
		GetArticleDetail:                 ctr.GetArticleDetail,
		GetArticleWithTagsList:           ctr.GetArticleWithTagsList,
		GetArticleWithTagDetail:          ctr.GetArticleWithTagDetail,
		GetArticleWithTagsListForPrivate: ctr.GetArticleWithTagsListForPrivate,
		CreateArticle:                    ctr.CreateArticle,
		GetHotArticle:                    ctr.GetHotArticle,

		UpdateArticle: ctr.UpdateBlogArticle,

		BlogSettingsList:   ctr.GetBlogSettingsList,
		UpdateBlogSettings: ctr.UpdateBlogSettings,
	}
}

type EsBlogHandler struct {
	SearchEsBlogArticle gin.HandlerFunc
}

func NewEsBlogHandler(svcCtx *svc.ServiceContext) *EsBlogHandler {
	ctr := NewEsBlogArticleController(svcCtx)
	return &EsBlogHandler{
		SearchEsBlogArticle: ctr.SearchEsBlogArticle,
	}
}
